<?php

namespace frontend\modules\wxad\controllers;

use frontend\modules\base\controllers\BaseController;
use Yii;
use frontend\modules\wxad\models\WxAd;
use frontend\modules\wxad\models\search\WxAdSearch;
use yii\base\Exception;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;

/**
 * 获取微信首页广告信息等
 *
 * Class WxadController
 * @package frontend\modules\wxad\controllers
 */
class WxadController extends BaseController
{
    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['POST'],
                ],
            ],
        ];
    }

    public $enableCsrfValidation = false;

    /**
     * 获取微信首页广告信息
     * 此接口无需传递任何验证信息
     *
     * @desc 获取微信广告信息 ，包括（图片 链接 广告名称）
     * @return array data[] 微信首页广告列表多维数组
     * @return string message 提示信息
     * @exception 200 获取数据成功
     * @exception 500 服务器内部错误
     * @return string
     */
    public function actionIndex()
    {
        $wxAdARR = WxAd::find()->where(['ad_cat_id'=>'7220fec0-d5a3-11e7-825c-631b33144ea8'])->asArray()->all();
        $message = ['code'=>200,'message'=>'广告信息获取成功','data'=>$wxAdARR];
        return json_encode($message);
    }
}
